/*
* created by chencheng 2016/10/25
* git url ：https://git.oschina.net/WatermeLonMan/gulp.git
*
*/
var express = require('express');
var crypto = require('crypto');
var mongodb = require('../model/moives');
var router = express.Router();

// 加密密码
function hasPw(pwd){
	return crypto.createHash('sha256').update(pwd).
			digest('base64').toString();
}
/* GET users listing. */
router.post('/', function(req, res, next) {
	var data = req.body;
	var User_info = mongodb.User_info;
	var userInfo  = new User_info({
		username:data.username,
		email:data.email,
		password:hasPw(data.password)
	});
	userInfo.save(function(err,data){
		if(err){
			console.log('error is '+err);
		}else{
			res.json({success:true});
		}
	});
});

module.exports = router;
